package cn.uexpo.lhz.controller.admin;



import cn.hutool.poi.excel.ExcelWriter;
import cn.hutool.poi.excel.StyleSet;
import cn.uexpo.lhz.biz.EquipmentTrafficBiz;
import cn.uexpo.lhz.biz.EventBiz;
import cn.uexpo.lhz.biz.StaffBiz;
import cn.uexpo.lhz.biz.TraffictotalSaveBiz;
import cn.uexpo.lhz.common.oldBase.BaseController;
import cn.uexpo.lhz.common.oldUtils.PageRequest;
import cn.uexpo.lhz.common.oldUtils.PageResult;
import cn.uexpo.lhz.common.utils.Base64Util;
import cn.uexpo.lhz.common.utils.DateTimeUtils;
import cn.uexpo.lhz.core.http.HttpResult;
import cn.uexpo.lhz.domain.*;
import cn.uexpo.lhz.domain.vo.EquipmentTrafficVo;
import com.alibaba.fastjson.JSONObject;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Font;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 *
 *设备通行
 * @author
 * @since
 */
//@CrossOrigin(origins = "*",allowedHeaders = "Access-Control-Allow-Origin")
@RestController
@RequestMapping("/admin/traffic")
public class EquipmentTrafficController extends BaseController<EquipmentTraffic>{

    @Autowired
    private EquipmentTrafficBiz equipmentTrafficBiz;

    @Autowired
    private TraffictotalSaveBiz traffictotalSaveBiz;

    @Autowired
    private StaffBiz staffBiz;

    @Autowired
    private EventBiz eventBiz;

    /**
     * 设备通行信息录入    比对
     * 根据项目表数据判断是否 将通行次数放入人员表
     * 1 是 去把通行次数改为1
     *
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/trafficData", method = { RequestMethod.POST })
    public Map<String, Object> data (HttpServletRequest request,HttpServletResponse response) throws Exception {
        String code = "500";
        String msg = "失败";
        int no = 0;
        int staffno = 0;
        Map<String, Object> map = new HashMap<String, Object>();
//        SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String name = request.getParameter("name");//设备名称
        String trafficResult = request.getParameter("matchResult");//通行结果
        String trafficTime = request.getParameter("matchTime");//通行时间
        String deviceId = request.getParameter("deviceId");//设备id
        String deviceInstallPosition = request.getParameter("deviceInstallPosition");//设备安装地址
        String projectName = request.getParameter("projectName");//项目名称
        String activeName = request.getParameter("activeName");//活动名称
        String staffId = request.getParameter("staffId");//比对人的ID
        String staffName = request.getParameter("staffName");//比对人的姓名
        String matchScore = request.getParameter("matchScore");//比对分值
        String captureImg = request.getParameter("captureImg");//现场照
        String idcImg = request.getParameter("idcImg");//身份证照
        String idcName = request.getParameter("idcName");//身份证名字
        String idcNumber = request.getParameter("idcNumber");//身份证号
        String gender  = request.getParameter("gender");//性别
        String birthday = request.getParameter("birthday");//生日
        String volk  = request.getParameter("volk");//民族
        String address = request.getParameter("address");//地址
        String icCard = request.getParameter("icCard");//ic卡号
        String projectRole = request.getParameter("projectRole");//项目角色
        if(null != DateTimeUtils.getDate(trafficTime)){
            EquipmentTraffic equipmentTraffic = new EquipmentTraffic();
            equipmentTraffic.setEquipmentname(name);
            equipmentTraffic.setTrafficresult(trafficResult);
            equipmentTraffic.setTraffictime(DateTimeUtils.getDate(trafficTime));
//        equipmentTraffic.setTraffictime(sdf.parse(trafficTime));
            equipmentTraffic.setDeviceid(deviceId);
            equipmentTraffic.setDeviceinstallposition(deviceInstallPosition);
            equipmentTraffic.setProjectname(projectName);
            equipmentTraffic.setActivename(activeName);
            equipmentTraffic.setStaffid(staffId);
            equipmentTraffic.setStaffname(staffName);
            equipmentTraffic.setMatchscore(matchScore);
            if(null!=captureImg&&!"".equals(captureImg)){
                equipmentTraffic.setCaptureimg(org.apache.tomcat.util.codec.binary.Base64.decodeBase64(captureImg));
            }
            if(null!=idcImg&&!"".equals(idcImg)){
                equipmentTraffic.setImg1(org.apache.tomcat.util.codec.binary.Base64.decodeBase64(idcImg));
            }
            equipmentTraffic.setExtstr1(idcName);
            equipmentTraffic.setExtstr2(idcNumber);
            equipmentTraffic.setExtstr3(gender);
            equipmentTraffic.setExtstr4(birthday);
            equipmentTraffic.setExtstr5(volk);
            equipmentTraffic.setExtstr6(address);
            equipmentTraffic.setExtstr7(icCard);
            equipmentTraffic.setExtstr8(projectRole);
            no = equipmentTrafficBiz.insert(equipmentTraffic);
            if("通行".equals(trafficResult)&&null!=projectName&&!"".equals(projectName)&&null!=staffId&&!"-1".equals(staffId)&&!"".equals(staffId)){
                EventExample example=new EventExample();
                EventExample.Criteria criteria=example.createCriteria();
                criteria.andNameEqualTo(projectName);
                List<Event> eventList=eventBiz.selectByExample(example);
                if(null!=eventList&&eventList.size()>0){
                    String state = eventList.get(0).getExtstr3();
                    if("1".equals(state)){
                        StaffExample staffExample = new StaffExample();
                        StaffExample.Criteria staffExampleCriteria = staffExample.createCriteria();
                        staffExampleCriteria.andStaffCardidEqualTo(idcNumber);//身份证号
                        staffExampleCriteria.andStaffIdEqualTo(Integer.parseInt(staffId));//id
                        staffExampleCriteria.andProjectTypeEqualTo(projectName);//项目名
                        List<Staff> staffList = staffBiz.selectByExample(staffExample);
                        if(null!=staffList&&staffList.size()>0){
                            Staff staff = staffList.get(0);
                            staff.setUntitled6("1");
                            staffno = staffBiz.updateByPrimaryKeySelective(staff);
                        }
                    }
                }
            }

        }else{
            code = "500";
            msg = "通行时间格式不正确";
        }

        if (1 == no && 1 == staffno) {
            code = "200";
            msg = "成功";
        } else if(1 == no && 1 != staffno){
            code = "200";
            msg = "通行记录成功";
        }
        map.put("code", code);
        map.put("msg", msg);
        return map;
    }


//    /**
//     * 设备通行信息录入    比对
//     * 去把通行次数换成1
//     * b
//     * @return
//     * @throws Exception
//     */
//    @RequestMapping(value = "/trafficData", method = { RequestMethod.POST })
//    public Map<String, Object> data (HttpServletRequest request,HttpServletResponse response) throws Exception {
//        String code = "500";
//        String msg = "失败";
//        int no = 0;
//        int staffno = 0;
//        Map<String, Object> map = new HashMap<String, Object>();
////        SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//
//        String name = request.getParameter("name");//设备名称
//        String trafficResult = request.getParameter("matchResult");//通行结果
//        String trafficTime = request.getParameter("matchTime");//通行时间
//        String deviceId = request.getParameter("deviceId");//设备id
//        String deviceInstallPosition = request.getParameter("deviceInstallPosition");//设备安装地址
//        String projectName = request.getParameter("projectName");//项目名称
//        String activeName = request.getParameter("activeName");//活动名称
//        String staffId = request.getParameter("staffId");//比对人的ID
//        String staffName = request.getParameter("staffName");//比对人的姓名
//        String matchScore = request.getParameter("matchScore");//比对分值
//        String captureImg = request.getParameter("captureImg");//现场照
//        String idcImg = request.getParameter("idcImg");//身份证照
//        String idcName = request.getParameter("idcName");//身份证名字
//        String idcNumber = request.getParameter("idcNumber");//身份证号
//        String gender  = request.getParameter("gender");//性别
//        String birthday = request.getParameter("birthday");//生日
//        String volk  = request.getParameter("volk");//民族
//        String address = request.getParameter("address");//地址
//        String icCard = request.getParameter("icCard");//ic卡号
//        String projectRole = request.getParameter("projectRole");//项目角色
//
//        if(null != DateTimeUtils.getDate(trafficTime)){
//
//            EquipmentTraffic equipmentTraffic = new EquipmentTraffic();
//            equipmentTraffic.setEquipmentname(name);
//            equipmentTraffic.setTrafficresult(trafficResult);
//            equipmentTraffic.setTraffictime(DateTimeUtils.getDate(trafficTime));
////        equipmentTraffic.setTraffictime(sdf.parse(trafficTime));
//            equipmentTraffic.setDeviceid(deviceId);
//            equipmentTraffic.setDeviceinstallposition(deviceInstallPosition);
//            equipmentTraffic.setProjectname(projectName);
//            equipmentTraffic.setActivename(activeName);
//            equipmentTraffic.setStaffid(staffId);
//            equipmentTraffic.setStaffname(staffName);
//            equipmentTraffic.setMatchscore(matchScore);
//
//            if(null!=captureImg&&!"".equals(captureImg)){
//                equipmentTraffic.setCaptureimg(Base64.decodeBase64(captureImg));
//            }
//            if(null!=idcImg&&!"".equals(idcImg)){
//                equipmentTraffic.setImg1(Base64.decodeBase64(idcImg));
//            }
//            equipmentTraffic.setExtstr1(idcName);
//            equipmentTraffic.setExtstr2(idcNumber);
//            equipmentTraffic.setExtstr3(gender);
//            equipmentTraffic.setExtstr4(birthday);
//            equipmentTraffic.setExtstr5(volk);
//            equipmentTraffic.setExtstr6(address);
//            equipmentTraffic.setExtstr7(icCard);
//            equipmentTraffic.setExtstr8(projectRole);
//            no = equipmentTrafficBiz.insert(equipmentTraffic);
//
//            //通行记录过来一条数据去数据库人员表查看是不是默认照片，是的话将抓拍图片放进去  staff_original_image
//            if(null!=staffId&&!"-1".equals(staffId)&&!"".equals(staffId)){
//                if("0".equals(trafficResult)){
//                    StaffExample staffExample = new StaffExample();
//                    StaffExample.Criteria criteria = staffExample.createCriteria();
//                    criteria.andStaffCardidEqualTo(idcNumber);//身份证号
//                    criteria.andStaffIdEqualTo(Integer.parseInt(staffId));//id
//                    criteria.andProjectTypeEqualTo(projectName);//项目名
//                    List<Staff> staffList = staffBiz.selectByExample(staffExample);
//                    if(null!=staffList&&staffList.size()>0){
//                        Staff staff = staffList.get(0);
//                        staff.setUntitled6("1");
//                        staffno = staffBiz.updateByPrimaryKeySelective(staff);
//                    }
//                }
//            }
//        }else{
//            code = "500";
//            msg = "通行时间格式不正确";
//        }
//
//        if (1 == no && 1 == staffno) {
//            code = "200";
//            msg = "成功";
//        } else if(1 == no && 1 != staffno){
//            code = "200";
//            msg = "无此人员信息";
//        }
//        map.put("code", code);
//
//        map.put("msg", msg);
//        return map;
//    }


//        /**
//     * 设备通行信息录入    比对
//     * jbh
//     * @return
//     * @throws Exception
//     */
//    @RequestMapping(value = "/trafficData", method = { RequestMethod.POST })
//    public Map<String, Object> data (HttpServletRequest request,HttpServletResponse response) throws Exception {
//        String code = "500";
//        String msg = "失败";
//        int no = 0;
//        Map<String, Object> map = new HashMap<String, Object>();
////        SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//        String name = request.getParameter("name");//设备名称
//        String trafficResult = request.getParameter("matchResult");//通行结果
//        String trafficTime = request.getParameter("matchTime");//通行时间
//        String deviceId = request.getParameter("deviceId");//设备id
//        String deviceInstallPosition = request.getParameter("deviceInstallPosition");//设备安装地址
//        String projectName = request.getParameter("projectName");//项目名称
//        String activeName = request.getParameter("activeName");//活动名称
//        String staffId = request.getParameter("staffId");//比对人的ID
//        String staffName = request.getParameter("staffName");//比对人的姓名
//        String matchScore = request.getParameter("matchScore");//比对分值
//        String captureImg = request.getParameter("captureImg");//现场照
//        String idcImg = request.getParameter("idcImg");//身份证照
//        String idcName = request.getParameter("idcName");//身份证名字
//        String idcNumber = request.getParameter("idcNumber");//身份证号
//        String gender  = request.getParameter("gender");//性别
//        String birthday = request.getParameter("birthday");//生日
//        String volk  = request.getParameter("volk");//民族
//        String address = request.getParameter("address");//地址
//        String icCard = request.getParameter("icCard");//ic卡号
//        String projectRole = request.getParameter("projectRole");//项目角色
//
//        if(null != DateTimeUtils.getDate(trafficTime)){
//
//            EquipmentTraffic equipmentTraffic = new EquipmentTraffic();
//            equipmentTraffic.setEquipmentname(name);
//            equipmentTraffic.setTrafficresult(trafficResult);
//            equipmentTraffic.setTraffictime(DateTimeUtils.getDate(trafficTime));
////        equipmentTraffic.setTraffictime(sdf.parse(trafficTime));
//            equipmentTraffic.setDeviceid(deviceId);
//            equipmentTraffic.setDeviceinstallposition(deviceInstallPosition);
//            equipmentTraffic.setProjectname(projectName);
//            equipmentTraffic.setActivename(activeName);
//            equipmentTraffic.setStaffid(staffId);
//            equipmentTraffic.setStaffname(staffName);
//            equipmentTraffic.setMatchscore(matchScore);
//
//            if(null!=captureImg&&!"".equals(captureImg)){
//                equipmentTraffic.setCaptureimg(Base64.decodeBase64(captureImg));
//            }
//            if(null!=idcImg&&!"".equals(idcImg)){
//                equipmentTraffic.setImg1(Base64.decodeBase64(idcImg));
//            }
//            equipmentTraffic.setExtstr1(idcName);
//            equipmentTraffic.setExtstr2(idcNumber);
//            equipmentTraffic.setExtstr3(gender);
//            equipmentTraffic.setExtstr4(birthday);
//            equipmentTraffic.setExtstr5(volk);
//            equipmentTraffic.setExtstr6(address);
//            equipmentTraffic.setExtstr7(icCard);
//            equipmentTraffic.setExtstr8(projectRole);
//            no = equipmentTrafficBiz.insert(equipmentTraffic);
//        }else{
//            code = "500";
//            msg = "通行时间格式不正确";
//        }
//        if (1 == no) {
//            code = "200";
//            msg = "成功";
//        }
//        map.put("code", code);
//
//        map.put("msg", msg);
//        return map;
//    }



//    /**
//     * 设备通行信息录入    比对
//     * 通行记录过来一条数据去数据库人员表查看是不是默认照片，是的话将抓拍图片放进去  staff_original_image
//     * @return
//     * @throws Exception
//     */
//    @RequestMapping(value = "/trafficData", method = { RequestMethod.POST })
//    public Map<String, Object> data (HttpServletRequest request,HttpServletResponse response) throws Exception {
//        String code = "500";
//        String msg = "失败";
//        int no = 0;
//        int staffno = 0;
//        Map<String, Object> map = new HashMap<String, Object>();
////        SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//
//        String name = request.getParameter("name");//设备名称
//        String trafficResult = request.getParameter("matchResult");//通行结果
//        String trafficTime = request.getParameter("matchTime");//通行时间
//        String deviceId = request.getParameter("deviceId");//设备id
//        String deviceInstallPosition = request.getParameter("deviceInstallPosition");//设备安装地址
//        String projectName = request.getParameter("projectName");//项目名称
//        String activeName = request.getParameter("activeName");//活动名称
//        String staffId = request.getParameter("staffId");//比对人的ID
//        String staffName = request.getParameter("staffName");//比对人的姓名
//        String matchScore = request.getParameter("matchScore");//比对分值
//        String captureImg = request.getParameter("captureImg");//现场照
//        String idcImg = request.getParameter("idcImg");//身份证照
//        String idcName = request.getParameter("idcName");//身份证名字
//        String idcNumber = request.getParameter("idcNumber");//身份证号
//        String gender  = request.getParameter("gender");//性别
//        String birthday = request.getParameter("birthday");//生日
//        String volk  = request.getParameter("volk");//民族
//        String address = request.getParameter("address");//地址
//        String icCard = request.getParameter("icCard");//ic卡号
//
//        if(null != DateTimeUtils.getDate(trafficTime)){
//
//            EquipmentTraffic equipmentTraffic = new EquipmentTraffic();
//            equipmentTraffic.setEquipmentname(name);
//            equipmentTraffic.setTrafficresult(trafficResult);
//            equipmentTraffic.setTraffictime(DateTimeUtils.getDate(trafficTime));
////        equipmentTraffic.setTraffictime(sdf.parse(trafficTime));
//            equipmentTraffic.setDeviceid(deviceId);
//            equipmentTraffic.setDeviceinstallposition(deviceInstallPosition);
//            equipmentTraffic.setProjectname(projectName);
//            equipmentTraffic.setActivename(activeName);
//            equipmentTraffic.setStaffid(staffId);
//            equipmentTraffic.setStaffname(staffName);
//            equipmentTraffic.setMatchscore(matchScore);
//
//            if(null!=captureImg&&!"".equals(captureImg)){
//                equipmentTraffic.setCaptureimg(Base64.decodeBase64(captureImg));
//            }
//            if(null!=idcImg&&!"".equals(idcImg)){
//                equipmentTraffic.setImg1(Base64.decodeBase64(idcImg));
//            }
//            equipmentTraffic.setExtstr1(idcName);
//            equipmentTraffic.setExtstr2(idcNumber);
//            equipmentTraffic.setExtstr3(gender);
//            equipmentTraffic.setExtstr4(birthday);
//            equipmentTraffic.setExtstr5(volk);
//            equipmentTraffic.setExtstr6(address);
//            equipmentTraffic.setExtstr7(icCard);
//            no = equipmentTrafficBiz.insert(equipmentTraffic);
//
//            //通行记录过来一条数据去数据库人员表查看是不是默认照片，是的话将抓拍图片放进去  staff_original_image
//            if(null!=staffId&&!"-1".equals(staffId)&&!"".equals(staffId)){
//
//                Staff staff = staffBiz.selectByPrimaryKey(Integer.parseInt(staffId));
//                String base64Default = "/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAH0AfQDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD3GiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiims4UZNADqKpSahGgIwc1Tkvyx+UkUAbNFYDXkh6O1NF3Nnl2/OgDoaKwlvXHVjVqLUUH3smgDToqGK5WXpU1ABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFVbq6EK9M596AHXF0sI5Gc1kz3bSH5WYVDLK0jEkmo6AFLE9TmkoooAKKKKACiiigB6yunRiK0ra/HRgTWVQCQeKAOnVgwzS1jWl4UO1snPvWurBhkUAOooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAoooJxQBFPMIlzxWDPKZHP1qzfz7yU44NUaACiiigAooooAKKKKACiiigAooooAAcGtSwusDaccmsunRttcH0NAHTA5oqvaTebFnjrVigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACoLqTy4d3vU9ZupSZiK570AZkrbpGb1NMoooAKKKKACiiigAooooAKKKKACiiigAooooA0NPm2lUz1NbFc5bNtuEPvXQRPvTNAD6KKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKK KKACiiigAooooAKKKKACiiigAooooAKKKKACiiigArEv2zK49626wL4/6U496AK1FFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFADkOHBrdsjutwfesAda3dOObUfWgC3RRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFYN8P8ASXPvW9WLqC4kY+9AFGiiigAooooAKKKKACiiigAooooAKKKKACiiigBR1rc04YtR9axIxlwK3rJdtuB70AWKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigArM1FMRlvetOq18m+DHvQBgUU5xtcj0ptABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFAEtuMzoPet+FdseKx7GLdKr+hrcoAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigApGGRilooAwryApIzYOCaqV0F1AJkAIrCkQo5GO9ADKKKKACiiigAooooAKKKKACiiigApVXcwHrSVfsbbedxB4NAF2xh8uLB6571cpAMUtABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABWbfWmQCg571pUjKGHNAHMkYJFJV69tvLIIHU1RoAKKKKACiiigAooooAKKKciF2AHrQBLbwNK2QMgGt2GJYlwoqG1txEvTGatUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQBBcxeYnTOK59hhiPeulf7h+lc7MMOfrQBHRRRQAUUUUAFFFFABV/TofMZiR0qhWtpYxvoA0hwKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooprMFGSRQAyaQIhz3Fc85y5+tXb268wgDsaoUAFFFFABRRRQAUUUUAFaWmSbSwNZtPjcowPvQB0tFVra5Eq9hj3qzQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUE4qN5UQcsBVC41AjIXBGaALss6xjORWVc3plOMYxVWSUyEk0ygAJyaKKKACiiigAooooAKKKKACiiigCSOUxnIrVtr7zBggCsalBwaAOmDqehBpawYLxoiBjjNakF2sgG5gD9aALVFIGBGQc0tABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFISAOaqzXsaA4bnFAFl5FQfMcVSuL9UB2MpqhNeySEjPFVic0ATTXLzE7sc1BRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFKrFWyKSigC/b37qQrYArSiuY5APnGa56pI5njOVNAHSA5FFZVvqHQSMMfStGOZJB8pzQBJRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFITigBailuEiHzGq1zeqnAJBrKkneQ8sSKALVxfs3CMcVSZ2c5Y5ptFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFTRXMkZ4bFQ0UAbUF8jcMxJq6GDdK5kMV6Grttespw7E80AbVFRxTLKuVqSgAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigArPvbrYuFJBzWhXP3bEzuMnrQBC7l2JJzTaKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAtW1y0bgbjjNbcUgkXIrmgcHNbemsWtyT60AXaKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAK526/wCPl/rXRVzt1/x8v9aAIaKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAK2tL/49j9axa2tL/wCPY/WgC9RRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAFFFFABWJewEOzAHk1t1HJEsgwaAObIxRW2dMhY5JNJ/ZcPqaAMWitr+y4fU0f2XD6mgDFora/suH1NH9lw+poAxaK2v7Lh9TR/ZcPqaAMWitr+y4fU0f2XD6mgDFora/suH1NH9lw+poAxaK2v7Lh9TR/ZcPqaAMWitr+y4fU0f2XD6mgDFora/suH1NH9lw+poAxaK2v7Lh9TR/ZcPqaAMWitr+y4fU0f2XD6mgDFora/suH1NH9lw+poAxaK2v7Lh9TR/ZcPqaAMWitr+y4fU0f2XD6mgDFora/suH1NH9lw+poAyI4y7AAVuWUflQke9EdlHEeCasgYoAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooAKKKKACiiigAooooA/9k=";
//                if(null!=staff){
//                    byte[] base64Blob = staff.getStaffOriginalImage();
//                    String base64Str = Base64.encodeBase64String(base64Blob).replace("\r\n", "");
//                    if(base64Default.equals(base64Str)){
//
//                        staff.setStaffOriginalImage(Base64.decodeBase64(captureImg));//将现场照放入
//                        staffno = staffBiz.updateByPrimaryKeyWithBLOBs(staff);
//                    }
//                }
//            }
//        }else{
//            code = "500";
//            msg = "通行时间格式不正确";
//        }
//
//
//
//        if (1 == no) {
//            code = "200";
//            msg = "成功";
//        }
//        map.put("code", code);
//
//        map.put("msg", msg);
//        return map;
//    }


    /**
     * 根据IC card 返回人员数据
     * 给手持机用
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/staffUserData", method = { RequestMethod.POST })
    public Map<String, Object> staffUserData (HttpServletRequest request,HttpServletResponse response) throws Exception {
        String code = "500";
        String msg = "失败";
        int no = 0;
        Map<String, Object> map = new HashMap<String, Object>();
        String icCard = request.getParameter("icCard");
        StaffExample example=new StaffExample();

        StaffExample.Criteria criteria= example.createCriteria();
        criteria.andIcCardEqualTo(icCard);
        List<Staff>  staffList=staffBiz.selectByExampleWithBLOBs(example);
//        List<Staff>  staffList=staffBiz.selectByExample(example);
        Staff staff = null;
        if(null!=staffList&&staffList.size()>0){
            staff = staffList.get(0);
            code = "200";
            msg = "成功";
        }
        map.put("code", code);
        map.put("staff",staff);
        map.put("msg", msg);
        return map;
    }

//	//分页显示
//	@PostMapping(value="/findPage")
//	public HttpResult findPage(@RequestBody cn.uexpo.lhz.common.oldUtils.PageRequest pageRequest) {
//		PageResult result=findPage1(pageRequest);
//		return HttpResult.ok(result);
//	}
//
//	private PageResult findPage1(@RequestBody cn.uexpo.lhz.common.oldUtils.PageRequest pageRequest) {
//		EquipmentTrafficExample example = new EquipmentTrafficExample();
//		example.setOrderByClause("equipmentTraffic_trafficTime desc");
//		PageResult result=equipmentTrafficBiz.findPage(pageRequest,example);
//		return result;
//	}

    //分页显示
//    @PostMapping(value="/findPage")
//    public HttpResult findPage(@RequestBody EquipmentTraffic equipmentTraffic) {
//        SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd");
//        PageRequest pageRequest = new PageRequest();
//        if(!"".equals(equipmentTraffic.getPageNum())&&!"".equals(equipmentTraffic.getPageSize())) {
//            pageRequest.setPageNum(equipmentTraffic.getPageNum());
//            pageRequest.setPageSize(equipmentTraffic.getPageSize());
//        }
//        PageResult result = null;
//        if(!"".equals(equipmentTraffic.getTraffictime())&&null!=equipmentTraffic.getTraffictime()) {
//            String str = f.format(equipmentTraffic.getTraffictime());
//            equipmentTraffic.setExtstr16(str);
//        }
//        result = equipmentTrafficBiz.findByDateList(pageRequest,equipmentTraffic);
//        return HttpResult.ok(result);
//    }



    /**
     * 数据展示 数据
     * * 第二版
     * 参数   项目  时间
     * all
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/countAll", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Map<String, Object> countAll() throws Exception {
        SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd");

        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH");

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        String code = "500";
        String msg = "失败";
        String name = request.getParameter("name");//项目名
        String dateT = request.getParameter("data");//日期

        List<JSONObject> list = new ArrayList<JSONObject>();
        Map<String, Object> map = new HashMap<String, Object>();

        if(null!=dateT){
            String startStr = (dateT+" 06:00:00").toString();
            String endStr = (dateT+" 22:00:00").toString();
            Date start = (Date)sdf.parse(startStr);
            Date end = (Date)sdf.parse(endStr);
//            String result = dateT.substring(dateT.length()-2,dateT.length());

            String result=dateT.substring(dateT.lastIndexOf("-",dateT.lastIndexOf("-"))+1);

            int dayj = Integer.parseInt(result);
            if (null != name && !"".equals(name)) {
                //   日期通行数据
                EquipmentTrafficExample trafficExample = new EquipmentTrafficExample();
                EquipmentTrafficExample.Criteria trafficCiteria = trafficExample.createCriteria();
                trafficCiteria.andProjectnameEqualTo(name);
                trafficCiteria.andTraffictimeGreaterThanOrEqualTo(start);//>=
                trafficCiteria.andTraffictimeLessThanOrEqualTo(end);//<=
                trafficCiteria.andTrafficresultEqualTo("通行");
                long count = equipmentTrafficBiz.countByExample(trafficExample);
                map.put("count", count);
                Date date = new Date();
                //  yyyy-MM-dd HH
                String time = df.format(date);
                date = df.parse(time); //整点时间


                Calendar cal = Calendar.getInstance();
                int day = cal.get(Calendar.DAY_OF_MONTH);    //获取当前天数
                int hour = cal.get(Calendar.HOUR_OF_DAY); //获取当前小时

                //时间点 时间段
                for (int i = 22; i >=6; i--) {

                    TraffictotalSaveExample traffictotalSaveExample = new TraffictotalSaveExample();
                    TraffictotalSaveExample.Criteria traffictotalSaveCriteria = traffictotalSaveExample.createCriteria();
                    traffictotalSaveCriteria.andTimeEqualTo((i-1)+"-"+i);
                    traffictotalSaveCriteria.andDayEqualTo(dateT+"");
                    traffictotalSaveCriteria.andExstr1EqualTo(name);
                    traffictotalSaveCriteria.andExstr3EqualTo("all");
                    List<TraffictotalSave> totalSaves = traffictotalSaveBiz.selectByExample(traffictotalSaveExample);
                    JSONObject object = new JSONObject();
                    if(null!=totalSaves&&totalSaves.size()>0){ //
                        String count22Two = totalSaves.get(0).getOntotalpassage();
                        object.put("onTotalPassage",count22Two);
                        object.put("time",(i-1)+"_"+i);
                        object.put("day",dayj);
                    }else{
                        Date datenew = new Date();
                        String timenew = f.format(datenew);
                        datenew = f.parse(timenew); //现在年月日

                        Date datecheck = f.parse(dateT);
                        //查询的年月日

                        int va = datenew.compareTo(datecheck); //比较时间 0 相等 1 大于  -1 小于
                        if(0==va){
                            if(i>hour){
                                object.put("onTotalPassage",0);
                                object.put("time",(i-1)+"_"+i);
                                object.put("day",dayj);
                            }else{
                                Calendar cal1 = Calendar.getInstance();
                                cal1.setTime(datecheck);
                                cal1.set(Calendar.HOUR_OF_DAY, i);// 24小时制
//                                cal1.set(Calendar.DAY_OF_MONTH,dayj);
                                cal1.set(Calendar.MINUTE, 0);
                                cal1.set(Calendar.SECOND, 0);
                                String one = sdf.format(cal1.getTime());
                                Date oneTime = sdf.parse(one);
                                Calendar cal2 = Calendar.getInstance();
                                cal2.setTime(datecheck);
//                                cal2.set(Calendar.DAY_OF_MONTH,dayj);
                                cal2.set(Calendar.HOUR_OF_DAY, i - 1);// 24小时制
                                cal2.set(Calendar.MINUTE, 0);
                                cal2.set(Calendar.SECOND, 0);
                                String two = sdf.format(cal2.getTime());
                                Date twoTime = sdf.parse(two);

                                EquipmentTrafficExample traffic27Example2 = new EquipmentTrafficExample();
                                EquipmentTrafficExample.Criteria traffic27Citeria2 = traffic27Example2.createCriteria();
                                traffic27Citeria2.andProjectnameEqualTo(name);
                                traffic27Citeria2.andTraffictimeGreaterThanOrEqualTo(twoTime);
                                if(i!=22){
                                    traffic27Citeria2.andTraffictimeLessThan(oneTime);//<
                                }else{
                                    traffic27Citeria2.andTraffictimeLessThanOrEqualTo(oneTime);
                                }
                                traffic27Citeria2.andTrafficresultEqualTo("通行");
                                long count22Two = equipmentTrafficBiz.countByExample(traffic27Example2);
                                object.put("onTotalPassage",count22Two);
                                object.put("time",(i-1)+"_"+i);
                                object.put("day",dayj);

                                TraffictotalSave traffictotalSave = new TraffictotalSave();
                                traffictotalSave.setDay(dateT+"");
                                traffictotalSave.setTime((i-1)+"-"+i);
                                traffictotalSave.setExstr1(name);
                                traffictotalSave.setExstr3("all");
                                traffictotalSave.setOntotalpassage(count22Two+"");
                                int no = traffictotalSaveBiz.insert(traffictotalSave);
                            }
                        }else if(-1==va){ //datenew小于等于datecheck
                            object.put("onTotalPassage",0);
                            object.put("time",(i-1)+"_"+i);
                            object.put("day",dayj);
                        }else if(1==va){
                            Calendar cal1 = Calendar.getInstance();
                            cal1.setTime(datecheck);
                            cal1.set(Calendar.HOUR_OF_DAY, i);// 24小时制
//                            cal1.set(Calendar.DAY_OF_MONTH,dayj);
                            cal1.set(Calendar.MINUTE, 0);
                            cal1.set(Calendar.SECOND, 0);
                            String one = sdf.format(cal1.getTime());
                            Date oneTime = sdf.parse(one);
                            Calendar cal2 = Calendar.getInstance();
                            cal2.setTime(datecheck);
//                            cal2.set(Calendar.DAY_OF_MONTH,dayj);
                            cal2.set(Calendar.HOUR_OF_DAY, i - 1);// 24小时制
                            cal2.set(Calendar.MINUTE, 0);
                            cal2.set(Calendar.SECOND, 0);
                            String two = sdf.format(cal2.getTime());
                            Date twoTime = sdf.parse(two);

                            EquipmentTrafficExample traffic27Example2 = new EquipmentTrafficExample();
                            EquipmentTrafficExample.Criteria traffic27Citeria2 = traffic27Example2.createCriteria();
                            traffic27Citeria2.andProjectnameEqualTo(name);
                            traffic27Citeria2.andTraffictimeGreaterThanOrEqualTo(twoTime);
                            if(i!=22){
                                traffic27Citeria2.andTraffictimeLessThan(oneTime);//<
                            }else{
                                traffic27Citeria2.andTraffictimeLessThanOrEqualTo(oneTime);//<=
                            }
                            traffic27Citeria2.andTrafficresultEqualTo("通行");
                            long count22Two = equipmentTrafficBiz.countByExample(traffic27Example2);

                            object.put("onTotalPassage",count22Two);
                            object.put("time",(i-1)+"_"+i);
                            object.put("day",dayj);

                            TraffictotalSave traffictotalSave = new TraffictotalSave();
                            traffictotalSave.setDay(dateT+"");
                            traffictotalSave.setTime((i-1)+"-"+i);
                            traffictotalSave.setExstr1(name);
                            traffictotalSave.setExstr3("all");
                            traffictotalSave.setOntotalpassage(count22Two+"");
                            int no = traffictotalSaveBiz.insert(traffictotalSave);
                        }
                    }

                    list.add(object);

                }

                code = "200";
                msg = "成功";

            } else {
                code = "500";
                msg = "项目名不能为空";
            }
        }




        map.put("data",list);
        map.put("code", code);
        map.put("msg", msg);
        return map;

    }


    /**
     * 数据展示 数据
     * * 第5版
     * 参数   项目  时间 筛选条件
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/countData", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Map<String, Object> countData() throws Exception {
        SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd");
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String code = "500";
        String msg = "失败";
        String name = request.getParameter("name");//项目名
        String dateT = request.getParameter("data");//日期
        String condition = request.getParameter("condition");//筛选条件
        Map<String, Object> map = new HashMap<String, Object>();
        if(null!=dateT){
            String startStr = (dateT+" 06:00:00").toString();
            String endStr = (dateT+" 22:00:00").toString();
            Date start = (Date)sdf.parse(startStr);
            Date end = (Date)sdf.parse(endStr);
            if (null != name && !"".equals(name)) {
                //   日期通行数据
                EquipmentTrafficExample trafficExample = new EquipmentTrafficExample();
                EquipmentTrafficExample.Criteria trafficCiteria = trafficExample.createCriteria();
                trafficCiteria.andProjectnameEqualTo(name);
                trafficCiteria.andTraffictimeGreaterThanOrEqualTo(start);//>=
                trafficCiteria.andTraffictimeLessThanOrEqualTo(end);//<=
                trafficCiteria.andTrafficresultEqualTo("通行");
                long count = 0;
                if("staffId".equals(condition)){
                    count = equipmentTrafficBiz.countByStaffidExample(trafficExample);
                }else if("idc".equals(condition)){
                    count = equipmentTrafficBiz.countByIdcExample(trafficExample);
                }else {
                    count = equipmentTrafficBiz.countByExample(trafficExample);
                }
                map.put("count", count);
                code = "200";
                msg = "成功";

            } else {
                code = "500";
                msg = "项目名不能为空";
            }
        }

        map.put("code", code);
        map.put("msg", msg);
        return map;

    }


    /**
     * 数据展示 数据
     * 第一版
     * 项目、时间固定
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/countDataAll", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Map<String, Object> countDataAll() throws Exception {
        SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd");

        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH");

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        String code = "500";
        String msg = "失败";
        List<JSONObject> list = new ArrayList<JSONObject>();
        Map<String, Object> map = new HashMap<String, Object>();
        String name = "2020华夏家博会";// 项目名称
        Date start25Time = sdf.parse("2020-06-25 06:00:00");
        Date end25Time = sdf.parse("2020-06-25 22:00:00");

        Date start26Time = sdf.parse("2020-06-26 06:00:00");
        Date end26Time = sdf.parse("2020-06-26 22:00:00");

        Date start27Time = sdf.parse("2020-06-27 06:00:00");
        Date end27Time = sdf.parse("2020-06-27 22:00:00");

        if (null != name && !"".equals(name)) {

            //  25日通行数据
            EquipmentTrafficExample traffic25Example = new EquipmentTrafficExample();
            EquipmentTrafficExample.Criteria traffic25Citeria = traffic25Example.createCriteria();
            traffic25Citeria.andProjectnameEqualTo(name);
            traffic25Citeria.andTraffictimeGreaterThanOrEqualTo(start25Time);//>=
//            traffic25Citeria.andTraffictimeLessThan(end25Time);//<
            traffic25Citeria.andTraffictimeLessThanOrEqualTo(end25Time);//<=
            traffic25Citeria.andTrafficresultEqualTo("通行");
            long count25 = equipmentTrafficBiz.countByExample(traffic25Example);
            //  26日通行数据
            EquipmentTrafficExample traffic26Example = new EquipmentTrafficExample();
            EquipmentTrafficExample.Criteria traffic26Citeria = traffic26Example.createCriteria();
            traffic26Citeria.andProjectnameEqualTo(name);
            traffic26Citeria.andTraffictimeGreaterThanOrEqualTo(start26Time);
//            traffic26Citeria.andTraffictimeLessThan(end26Time);//<
            traffic26Citeria.andTraffictimeLessThanOrEqualTo(end26Time);//<=
            traffic26Citeria.andTrafficresultEqualTo("通行");
            long count26 = equipmentTrafficBiz.countByExample(traffic26Example);
            //  27日通行数据
            EquipmentTrafficExample traffic27Example = new EquipmentTrafficExample();
            EquipmentTrafficExample.Criteria traffic27Citeria = traffic27Example.createCriteria();
            traffic27Citeria.andProjectnameEqualTo(name);
            traffic27Citeria.andTraffictimeGreaterThanOrEqualTo(start27Time);
//            traffic27Citeria.andTraffictimeLessThan(end27Time);//<
            traffic27Citeria.andTraffictimeLessThanOrEqualTo(end27Time);//<=
            traffic27Citeria.andTrafficresultEqualTo("通行");
            long count27 = equipmentTrafficBiz.countByExample(traffic27Example);

            map.put("count25", count25);
            map.put("count26", count26);
            map.put("count27", count27);

            Date date = new Date();
            // 得到 整数时间
            String time = df.format(date);
            date = df.parse(time);
            Calendar cal = Calendar.getInstance();
            int day = cal.get(Calendar.DAY_OF_MONTH);    //获取当前天数
            int hour = cal.get(cal.HOUR_OF_DAY);

            //时间点 时间段
            for (int i = 22; i >=6; i--) {

                for(int dayj = 25;dayj<=27;dayj++){
                    TraffictotalSaveExample traffictotalSaveExample = new TraffictotalSaveExample();
                    TraffictotalSaveExample.Criteria traffictotalSaveCriteria = traffictotalSaveExample.createCriteria();
                    traffictotalSaveCriteria.andTimeEqualTo((i-1)+"-"+i);
                    traffictotalSaveCriteria.andDayEqualTo(dayj+"");
                    traffictotalSaveCriteria.andExstr1EqualTo(name);
                    List<TraffictotalSave> totalSaves = traffictotalSaveBiz.selectByExample(traffictotalSaveExample);

                    JSONObject object = new JSONObject();
                    if(null!=totalSaves&&totalSaves.size()>0){
//                        object.put(dayj+"_"+(i-1)+"-"+i,totalSaves.get(0).getOntotalpassage());
                        String count22Two = totalSaves.get(0).getOntotalpassage();
                        object.put("onTotalPassage",count22Two);
                        object.put("time",(i-1)+"_"+i);
                        object.put("day",dayj);
                    }else{

                        if(day == dayj){
                            if(i>hour){
                                object.put("onTotalPassage",0);
                                object.put("time",(i-1)+"_"+i);
                                object.put("day",dayj);
                            }else{
                                Calendar cal1 = Calendar.getInstance();
                                cal1.setTime(date);
                                cal1.set(Calendar.HOUR_OF_DAY, i);// 24小时制
                                cal1.set(Calendar.DAY_OF_MONTH,dayj);
                                cal1.set(Calendar.MINUTE, 0);
                                cal1.set(Calendar.SECOND, 0);
                                String one = sdf.format(cal1.getTime());
                                Date oneTime = sdf.parse(one);
                                Calendar cal2 = Calendar.getInstance();
                                cal2.setTime(date);
                                cal2.set(Calendar.DAY_OF_MONTH,dayj);
                                cal2.set(Calendar.HOUR_OF_DAY, i - 1);// 24小时制
                                cal2.set(Calendar.MINUTE, 0);
                                cal2.set(Calendar.SECOND, 0);
                                String two = sdf.format(cal2.getTime());
                                Date twoTime = sdf.parse(two);

                                EquipmentTrafficExample traffic27Example2 = new EquipmentTrafficExample();
                                EquipmentTrafficExample.Criteria traffic27Citeria2 = traffic27Example2.createCriteria();
                                traffic27Citeria2.andProjectnameEqualTo(name);
                                traffic27Citeria2.andTraffictimeGreaterThanOrEqualTo(twoTime);
                                if(i!=22){
                                    traffic27Citeria2.andTraffictimeLessThan(oneTime);//<
                                }else{
                                    traffic27Citeria2.andTraffictimeLessThanOrEqualTo(oneTime);
                                }
//                                traffic27Citeria2.andTraffictimeLessThan(oneTime);//<
//                                traffic27Citeria2.andTraffictimeLessThanOrEqualTo(oneTime);
                                traffic27Citeria2.andTrafficresultEqualTo("通行");
                                long count22Two = equipmentTrafficBiz.countByExample(traffic27Example2);
                                object.put("onTotalPassage",count22Two);
                                object.put("time",(i-1)+"_"+i);
                                object.put("day",dayj);

                                TraffictotalSave traffictotalSave = new TraffictotalSave();
                                traffictotalSave.setDay(dayj+"");
                                traffictotalSave.setTime((i-1)+"-"+i);
                                traffictotalSave.setExstr1(name);
                                traffictotalSave.setOntotalpassage(count22Two+"");
                                int no = traffictotalSaveBiz.insert(traffictotalSave);
                            }
                        }else if(day < dayj){
                            object.put("onTotalPassage",0);
                            object.put("time",(i-1)+"_"+i);
                            object.put("day",dayj);
                        }else if(day > dayj){
                            Calendar cal1 = Calendar.getInstance();
                            cal1.setTime(date);
                            cal1.set(Calendar.HOUR_OF_DAY, i);// 24小时制
                            cal1.set(Calendar.DAY_OF_MONTH,dayj);
                            cal1.set(Calendar.MINUTE, 0);
                            cal1.set(Calendar.SECOND, 0);
                            String one = sdf.format(cal1.getTime());
                            Date oneTime = sdf.parse(one);
                            Calendar cal2 = Calendar.getInstance();
                            cal2.setTime(date);
                            cal2.set(Calendar.DAY_OF_MONTH,dayj);
                            cal2.set(Calendar.HOUR_OF_DAY, i - 1);// 24小时制
                            cal2.set(Calendar.MINUTE, 0);
                            cal2.set(Calendar.SECOND, 0);
                            String two = sdf.format(cal2.getTime());
                            Date twoTime = sdf.parse(two);

                            EquipmentTrafficExample traffic27Example2 = new EquipmentTrafficExample();
                            EquipmentTrafficExample.Criteria traffic27Citeria2 = traffic27Example2.createCriteria();
                            traffic27Citeria2.andProjectnameEqualTo(name);
                            traffic27Citeria2.andTraffictimeGreaterThanOrEqualTo(twoTime);
                            if(i!=22){
                                traffic27Citeria2.andTraffictimeLessThan(oneTime);//<
                            }else{
                                traffic27Citeria2.andTraffictimeLessThanOrEqualTo(oneTime);//<=
                            }
//                            traffic27Citeria2.andTraffictimeLessThan(oneTime);//<
//                            traffic27Citeria2.andTraffictimeLessThanOrEqualTo(oneTime);
                            traffic27Citeria2.andTrafficresultEqualTo("通行");
                            long count22Two = equipmentTrafficBiz.countByExample(traffic27Example2);

                            object.put("onTotalPassage",count22Two);
                            object.put("time",(i-1)+"_"+i);
                            object.put("day",dayj);

                            TraffictotalSave traffictotalSave = new TraffictotalSave();
                            traffictotalSave.setDay(dayj+"");
                            traffictotalSave.setTime((i-1)+"-"+i);
                            traffictotalSave.setExstr1(name);
                            traffictotalSave.setOntotalpassage(count22Two+"");
                            int no = traffictotalSaveBiz.insert(traffictotalSave);
                        }
                    }

                    list.add(object);

                }
            }

            code = "200";
            msg = "成功";

        } else {
            code = "500";
            msg = "项目名不能为空";
        }

        map.put("data",list);
        map.put("code", code);
        map.put("msg", msg);
        return map;

    }










    /**
     * 数据展示 数据
     * * 第六版
     * 参数   项目  时间
     * 筛选
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/countDistinctAll", method = { RequestMethod.GET, RequestMethod.POST })
    @ResponseBody
    public Map<String, Object> countDistinctAll() throws Exception {
        SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd");

        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH");

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        String code = "500";
        String msg = "失败";
        String name = request.getParameter("name");//项目名
        String dateT = request.getParameter("data");//日期
        String condition = request.getParameter("condition");//筛选条件

        List<JSONObject> list = new ArrayList<JSONObject>();
        Map<String, Object> map = new HashMap<String, Object>();

        if(null!=dateT){
            String startStr = (dateT+" 06:00:00").toString();
            String endStr = (dateT+" 22:00:00").toString();
            Date start = (Date)sdf.parse(startStr);
            Date end = (Date)sdf.parse(endStr);
//            String result = dateT.substring(dateT.length()-2,dateT.length());

            String result=dateT.substring(dateT.lastIndexOf("-",dateT.lastIndexOf("-"))+1);

            int dayj = Integer.parseInt(result);
            if (null != name && !"".equals(name)) {
                //   日期通行数据
                EquipmentTrafficExample trafficExample = new EquipmentTrafficExample();
                EquipmentTrafficExample.Criteria trafficCiteria = trafficExample.createCriteria();
                trafficCiteria.andProjectnameEqualTo(name);
                trafficCiteria.andTraffictimeGreaterThanOrEqualTo(start);//>=
                trafficCiteria.andTraffictimeLessThanOrEqualTo(end);//<=
                trafficCiteria.andTrafficresultEqualTo("通行");
                long count = 0;
                if("staffId".equals(condition)){
                    count = equipmentTrafficBiz.countByStaffidExample(trafficExample);
                }else if("idc".equals(condition)){
                    count = equipmentTrafficBiz.countByIdcExample(trafficExample);
                }else {
                    count = equipmentTrafficBiz.countByExample(trafficExample);
                }
                map.put("count", count);
                Date date = new Date();
                //  yyyy-MM-dd HH
                String time = df.format(date);
                date = df.parse(time); //整点时间


                Calendar cal = Calendar.getInstance();
                int day = cal.get(Calendar.DAY_OF_MONTH);    //获取当前天数
                int hour = cal.get(Calendar.HOUR_OF_DAY); //获取当前小时

                //时间点 时间段
                for (int i = 22; i >=6; i--) {

                    TraffictotalSaveExample traffictotalSaveExample = new TraffictotalSaveExample();
                    TraffictotalSaveExample.Criteria traffictotalSaveCriteria = traffictotalSaveExample.createCriteria();
                    traffictotalSaveCriteria.andTimeEqualTo((i-1)+"-"+i);
                    traffictotalSaveCriteria.andDayEqualTo(dateT+"");
                    traffictotalSaveCriteria.andExstr1EqualTo(name);
                    traffictotalSaveCriteria.andExstr3EqualTo(condition);
                    List<TraffictotalSave> totalSaves = traffictotalSaveBiz.selectByExample(traffictotalSaveExample);
                    JSONObject object = new JSONObject();
                    if(null!=totalSaves&&totalSaves.size()>0){ //
                        String count22Two = totalSaves.get(0).getOntotalpassage();
                        object.put("onTotalPassage",count22Two);
                        object.put("time",(i-1)+"_"+i);
                        object.put("day",dayj);
                    }else{
                        Date datenew = new Date();
                        String timenew = f.format(datenew);
                        datenew = f.parse(timenew); //现在年月日

                        Date datecheck = f.parse(dateT);
                        //查询的年月日

                        int va = datenew.compareTo(datecheck); //比较时间 0 相等 1 大于  -1 小于
                        if(0==va){
                            if(i>hour){
                                object.put("onTotalPassage",0);
                                object.put("time",(i-1)+"_"+i);
                                object.put("day",dayj);
                            }else{
                                Calendar cal1 = Calendar.getInstance();
                                cal1.setTime(datecheck);
                                cal1.set(Calendar.HOUR_OF_DAY, i);// 24小时制
//                                cal1.set(Calendar.DAY_OF_MONTH,dayj);
                                cal1.set(Calendar.MINUTE, 0);
                                cal1.set(Calendar.SECOND, 0);
                                String one = sdf.format(cal1.getTime());
                                Date oneTime = sdf.parse(one);
                                Calendar cal2 = Calendar.getInstance();
                                cal2.setTime(datecheck);
//                                cal2.set(Calendar.DAY_OF_MONTH,dayj);
                                cal2.set(Calendar.HOUR_OF_DAY, i - 1);// 24小时制
                                cal2.set(Calendar.MINUTE, 0);
                                cal2.set(Calendar.SECOND, 0);
                                String two = sdf.format(cal2.getTime());
                                Date twoTime = sdf.parse(two);

                                EquipmentTrafficExample traffic27Example2 = new EquipmentTrafficExample();
                                EquipmentTrafficExample.Criteria traffic27Citeria2 = traffic27Example2.createCriteria();
                                traffic27Citeria2.andProjectnameEqualTo(name);
                                traffic27Citeria2.andTraffictimeGreaterThanOrEqualTo(start);
                                if(i!=22){
                                    traffic27Citeria2.andTraffictimeLessThan(oneTime);//<
                                }else{
                                    traffic27Citeria2.andTraffictimeLessThanOrEqualTo(oneTime);
                                }
                                traffic27Citeria2.andTrafficresultEqualTo("通行");
                                long countBTwo = equipmentTrafficBiz.countByExample(traffic27Example2);

                                EquipmentTrafficExample trafficAExample2 = new EquipmentTrafficExample();
                                EquipmentTrafficExample.Criteria trafficACiteria2 = trafficAExample2.createCriteria();
                                trafficACiteria2.andProjectnameEqualTo(name);
                                trafficACiteria2.andTraffictimeGreaterThanOrEqualTo(start);
                                if(i!=22){
                                    trafficACiteria2.andTraffictimeLessThan(twoTime);//<
                                }else{
                                    trafficACiteria2.andTraffictimeLessThanOrEqualTo(twoTime);
                                }
                                trafficACiteria2.andTrafficresultEqualTo("通行");
                                long countATwo = equipmentTrafficBiz.countByExample(trafficAExample2);

                                object.put("onTotalPassage",countBTwo-countATwo);
                                object.put("time",(i-1)+"_"+i);
                                object.put("day",dayj);

                                TraffictotalSave traffictotalSave = new TraffictotalSave();
                                traffictotalSave.setDay(dateT+"");
                                traffictotalSave.setTime((i-1)+"-"+i);
                                traffictotalSave.setExstr1(name);
                                if("staffId".equals(condition)){
                                    count = equipmentTrafficBiz.countByStaffidExample(trafficExample);
                                }else if("idc".equals(condition)){
                                    count = equipmentTrafficBiz.countByIdcExample(trafficExample);
                                }else {
                                    count = equipmentTrafficBiz.countByExample(trafficExample);
                                }
                                traffictotalSave.setExstr3("all");
                                traffictotalSave.setOntotalpassage(countBTwo-countATwo+"");
                                int no = traffictotalSaveBiz.insert(traffictotalSave);
                            }
                        }else if(-1==va){ //datenew小于等于datecheck
                            object.put("onTotalPassage",0);
                            object.put("time",(i-1)+"_"+i);
                            object.put("day",dayj);
                        }else if(1==va){
                            Calendar cal1 = Calendar.getInstance();
                            cal1.setTime(datecheck);
                            cal1.set(Calendar.HOUR_OF_DAY, i);// 24小时制
//                                cal1.set(Calendar.DAY_OF_MONTH,dayj);
                            cal1.set(Calendar.MINUTE, 0);
                            cal1.set(Calendar.SECOND, 0);
                            String one = sdf.format(cal1.getTime());
                            Date oneTime = sdf.parse(one);
                            Calendar cal2 = Calendar.getInstance();
                            cal2.setTime(datecheck);
//                                cal2.set(Calendar.DAY_OF_MONTH,dayj);
                            cal2.set(Calendar.HOUR_OF_DAY, i - 1);// 24小时制
                            cal2.set(Calendar.MINUTE, 0);
                            cal2.set(Calendar.SECOND, 0);
                            String two = sdf.format(cal2.getTime());
                            Date twoTime = sdf.parse(two);

                            EquipmentTrafficExample traffic27Example2 = new EquipmentTrafficExample();
                            EquipmentTrafficExample.Criteria traffic27Citeria2 = traffic27Example2.createCriteria();
                            traffic27Citeria2.andProjectnameEqualTo(name);
                            traffic27Citeria2.andTraffictimeGreaterThanOrEqualTo(start);
                            if(i!=22){
                                traffic27Citeria2.andTraffictimeLessThan(oneTime);//<
                            }else{
                                traffic27Citeria2.andTraffictimeLessThanOrEqualTo(oneTime);
                            }
                            traffic27Citeria2.andTrafficresultEqualTo("通行");
                            long countBTwo = equipmentTrafficBiz.countByExample(traffic27Example2);

                            EquipmentTrafficExample trafficAExample2 = new EquipmentTrafficExample();
                            EquipmentTrafficExample.Criteria trafficACiteria2 = trafficAExample2.createCriteria();
                            trafficACiteria2.andProjectnameEqualTo(name);
                            trafficACiteria2.andTraffictimeGreaterThanOrEqualTo(start);
                            if(i!=22){
                                trafficACiteria2.andTraffictimeLessThan(twoTime);//<
                            }else{
                                trafficACiteria2.andTraffictimeLessThanOrEqualTo(twoTime);
                            }
                            trafficACiteria2.andTrafficresultEqualTo("通行");
                            long countATwo = equipmentTrafficBiz.countByExample(trafficAExample2);

                            object.put("onTotalPassage",countBTwo-countATwo);
                            object.put("time",(i-1)+"_"+i);
                            object.put("day",dayj);

                            TraffictotalSave traffictotalSave = new TraffictotalSave();
                            traffictotalSave.setDay(dateT+"");
                            traffictotalSave.setTime((i-1)+"-"+i);
                            traffictotalSave.setExstr1(name);
                            if("staffId".equals(condition)){
                                count = equipmentTrafficBiz.countByStaffidExample(trafficExample);
                            }else if("idc".equals(condition)){
                                count = equipmentTrafficBiz.countByIdcExample(trafficExample);
                            }else {
                                count = equipmentTrafficBiz.countByExample(trafficExample);
                            }
                            traffictotalSave.setExstr3("all");
                            traffictotalSave.setOntotalpassage(countBTwo-countATwo+"");
                            int no = traffictotalSaveBiz.insert(traffictotalSave);
                        }
                    }

                    list.add(object);

                }

                code = "200";
                msg = "成功";

            } else {
                code = "500";
                msg = "项目名不能为空";
            }
        }
        map.put("data",list);
        map.put("code", code);
        map.put("msg", msg);
        return map;

    }


    /**
     * vue下拉框项目 通行结果展示
     *
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/dataList", method = { RequestMethod.POST })
    @ResponseBody

    public Map<String, Object> data() throws Exception {
        Map<String, Object> map = new HashMap<String, Object>();
        List<JSONObject> nameList = new ArrayList<JSONObject>();
        List<String> results = equipmentTrafficBiz.selectDistinctResults();
        for (String result : results) {
            JSONObject obj = new JSONObject();
            obj.put("result", result);
            nameList.add(obj);
        }
        map.put("results", nameList);
        return map;
    }



    private void getStyle(ExcelWriter writer) {
        // 定义单元格背景色
        StyleSet style = writer.getStyleSet();
        CellStyle headCellStyle = style.getHeadCellStyle();
        // 第二个参数表示是否也设置头部单元格背景
        // style.setBackgroundColor(IndexedColors.RED, false);
        //. 自定义字体
        Font font = writer.createFont();
        font.setBold(true);
        font.setColor(Font.COLOR_RED);
        font.setItalic(true);
        //第二个参数表示是否忽略头部样式
        writer.getStyleSet().setFont(font, true);

        //自定义标题别名
        writer.addHeaderAlias("captureimg", "现场照");
        writer.addHeaderAlias("staffname", "名字");
        writer.addHeaderAlias("trafficresult", "通行结果");
        writer.addHeaderAlias("extstr7", "ic卡号");
        writer.addHeaderAlias("equipmentname", "设备名");
        writer.addHeaderAlias("traffictime", "通行时间");
        writer.addHeaderAlias("deviceinstallposition", "安装地址");
        writer.addHeaderAlias("projectname", "项目名称");
        writer.addHeaderAlias("activename", "活动名");
        writer.addHeaderAlias("img1", "身份证照片");
        writer.addHeaderAlias("extstr1", "身份名字");
        writer.addHeaderAlias("extstr2", "身份证号");
        writer.addHeaderAlias("extstr3", "性别");
        writer.addHeaderAlias("extstr4", "生日");
        writer.addHeaderAlias("extstr5", "民族");
        writer.addHeaderAlias("extstr6", "地址");
        writer.addHeaderAlias("matchscore", "比对分值");
        writer.addHeaderAlias("deviceId", "设备id");

        writer.setColumnWidth(0, 13);
        writer.setColumnWidth(5, 15);
        writer.setColumnWidth(8, 13);
        writer.setColumnWidth(9, 13);
        writer.setColumnWidth(11, 18);
        writer.setColumnWidth(12, 20);
        writer.setColumnWidth(13, 20);
        writer.setColumnWidth(15, 30);
//        writer.setColumnWidth(6, 15);
        writer.merge(13, "设备通行", true);
    }


    @PostMapping(value = "/findPageExport")
    public void findPageExport(@RequestBody EquipmentTrafficVo equipmentTrafficVo) throws IOException {
      //  long startTime = System.currentTimeMillis();   //获取开始时间
//        PageRequest pageRequest = new PageRequest();
//        if (!"".equals(equipmentTraffic.getPageNum()) && !"".equals(equipmentTraffic.getPageSize())) {
//            pageRequest.setPageNum(equipmentTraffic.getPageNum());
//            pageRequest.setPageSize(equipmentTraffic.getPageSize());
//        }
//        PageResult result = equipmentTrafficBiz.findPage2(pageRequest, equipmentTraffic);

//
        List<EquipmentTrafficVo> equipmentTraffics = equipmentTrafficBiz.listEquipmentTrafficVo(equipmentTrafficVo);
      //  System.out.println(equipmentTraffics);
        //List<EquipmentTraffic> content = (List<EquipmentTraffic>) result.getContent();

//        List<EquipmentTrafficVo> trafficVo = equipmentTraffics.stream().map((e -> {
//            EquipmentTrafficVo vo = new EquipmentTrafficVo();
//            BeanUtils.copyProperties(e, vo);
//            return vo;
//        })).collect(Collectors.toList());
//
//        List<EquipmentTrafficVo> rows = null;
//        for (int a = 0; a < trafficVo.size(); a++) {
//            rows = CollUtil.newArrayList(trafficVo);
//        }
//        // 通过工具类创建writer，默认创建xls格式
//        ExcelWriter writer = ExcelUtil.getWriter();
//        getStyle(writer);
//
//        // 一次性写出内容，使用默认样式，强制输出标题
//        writer.write(rows, true);
        //out为OutputStream，需要写出到的目标流



//        long endTime = System.currentTimeMillis(); //获取结束时间
//        long l = endTime - startTime;
//        System.out.println("导出共耗时>>>>>>>>" + l + "毫秒");
//        response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
//        ServletOutputStream out = response.getOutputStream();
//        writer.flush(out, true);
//        writer.close();
//        IoUtil.close(out);


    }

    /**
     * 图片处理
     * @return
     * @throws IOException
     */
    @PostMapping(value="/findPageTest")
    public HttpResult findPageTest() throws IOException {
        SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd");
//        PageRequest pageRequest = new PageRequest();
//        if(!"".equals(equipmentTraffic.getPageNum())&&!"".equals(equipmentTraffic.getPageSize())) {
//            pageRequest.setPageNum(equipmentTraffic.getPageNum());
//            pageRequest.setPageSize(equipmentTraffic.getPageSize());
//        }
//        PageResult result = null;
//        if(!"".equals(equipmentTraffic.getTraffictime())&&null!=equipmentTraffic.getTraffictime()) {
//            String str = f.format(equipmentTraffic.getTraffictime());
//            equipmentTraffic.setExtstr16(str);
//        }
//        result = equipmentTrafficBiz.findByDateList(pageRequest,equipmentTraffic);

        EquipmentTrafficExample traffic27Example2 = new EquipmentTrafficExample();
        EquipmentTrafficExample.Criteria traffic27Citeria2 = traffic27Example2.createCriteria();
        traffic27Citeria2.andProjectnameEqualTo("哔哩哔哩");
        List<EquipmentTraffic> equipmentTraffics = equipmentTrafficBiz.selectByExampleWithBLOBs(traffic27Example2);

        //当前项目下路径
        File file = new File("");
        String filePath = file.getCanonicalPath();
        System.out.println(filePath);
        String path = filePath+"\\src\\main\\resources\\static";
        System.out.println(path);
//        List<EquipmentTraffic> equipmentTraffics = (List<EquipmentTraffic>) result.getContent();


        for(EquipmentTraffic traffic : equipmentTraffics){
            byte[] blob = traffic.getCaptureimg();
//            System.out.println(blob);
            if(null!=blob&&!"".equals(blob)&&!"null".equals(blob)){
                String base64Img = Base64.getEncoder().encodeToString(blob);
                boolean b = Base64Util.Base64ToImage(base64Img,path+"\\"+traffic.getId()+".jpg");
                System.out.println(b);
            }
        }

        return HttpResult.ok("1");
    }





}

